package com.du.web.sample.util.water;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

import java.io.*;

/**
 * @desc:
 * @author: shuangdu
 * @date: 2021/9/14
 * @since: 1.8
 */
@Slf4j
public abstract class WaterMaker {

    public WaterMakeParam waterMakeParam;

    public String outSrcPath = "/";

    public WaterMaker(WaterMakeParam waterMakeParam) {
        if (StrUtil.isEmpty(waterMakeParam.getFileName())) {
            throw new NullPointerException("文件名称不能为空");
        }
        this.waterMakeParam = waterMakeParam;
    }

    public String makeOutFileName() {
        return waterMakeParam.getFileName().substring(0, waterMakeParam.getFileName().lastIndexOf("."))
                + System.currentTimeMillis() + "." + waterMakeParam.getExtName();
    }

    /**
     * 制作水印
     */
    public abstract void doMake();

}
